package written.test;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * @Author: Dang Qi
 * @Date: 2021/4/21  20:10
 * @Description:
 */
public class Hitguai {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), W = sc.nextInt(), H = sc.nextInt(), R = sc.nextInt();
        int[][] guaishou = new int[N][3];
        for (int i = 0; i < N; i++){
            for(int j = 0; j < 3; j++) guaishou[i][j] = sc.nextInt();
        }
        int M = sc.nextInt();
        for (int i = 0; i < M; i++){
            int x = sc.nextInt(), y = sc.nextInt(), r = sc.nextInt();
            kill(x, y, r, R, guaishou);
        }
    }
    public static void kill(int x, int y, int r, int R, int[][] guaiwu){
        List<Integer> ans = new ArrayList<>();
        for(int i = 0; i < guaiwu.length; i++){
            if(isInSkil(x-guaiwu[i][1], y - guaiwu[i][2], r))
                ans.add(guaiwu[i][0]);
        }
        System.out.print(ans.size());
        ans.stream().forEach(n-> System.out.print(" "+n));
        System.out.println();
    }
    public static boolean isInSkil(int x, int y, int r){
        return Math.sqrt(x*x+y*y) <= r;
    }
}
